#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import sys

def getTime():
    import time
    return time.strftime('%Y%m%d%H%M%S',time.localtime())

if __name__ == "__main__":
    infile=open(sys.argv[1],'r')
    filter_fields=sys.argv[2]

    fields={}
    for item in filter_fields.split(","):
        fields[item]=0

    outfile=open("node_node_"+getTime()+".txt","w")

    for line in infile:
        line=line.rstrip()
        splitline=line.split("====")
        if not fields.has_key(splitline[0]):
            spp=splitline[1].split(";")
            itt=""
            for item in spp:
                if not fields.has_key(item):
                    if item!=splitline[0]:
                        itt+=item+";"
            if itt!="":
                itt=itt[:-1]
                outfile.write(splitline[0]+"===="+itt+"\n")
                outfile.flush()
    infile.close()
    outfile.close()